package 力扣日常刷题.木23一月.第12天312;

import 力扣日常刷题.ListNode;

/**
 * @author 帅小伙
 * @date 2022/3/12
 * @description
 */
public class Demo49合并两个链表 {


    public ListNode mergeTwoLists(ListNode l1,ListNode l2) {
        if(l1 == null || l2 == null) {
            return l1 == null ? l2 : l1;
        }

        if(l1.val > l2.val) {
            l2.next = mergeTwoLists(l1,l2.next);
            return l2;
        }else{
            l1.next = mergeTwoLists(l1.next,l2);
            return l1;
        }
    }

}
